(function (_$, $, doc) {
    $.init();
    $.ready(function () {
        // var adress = {};
        var cityResult3 = doc.getElementById('cityResult3');
        // 实时定位
        _$(function () {
            getLocation_bd(function (e) {
                var adressDetail = e.province +
                    e.cityname +
                    (e.district ? e.district : '') +
                    (e.street ? e.street : '');
                cityResult3 && _$(cityResult3).removeAttr('readonly').val(adressDetail).attr('readonly', 'true');
            }, function (e) {
                cityResult3 && _$(cityResult3).val('地理位置获取失败');
            });

            //-----------------------------------------
            if (cityResult3) {
                // 级联
                var cityPicker3 = new $.PopPicker({
                    layer: 3
                });
                cityPicker3.setData(cityData3);

                _$(doc).on('tap', '.icon-editCity', function (event) {
                    event.stopPropagation();
                    _$(cityResult3).removeAttr('readonly').focus();
                    // 移除弹出3级选择弹出事件
                    _$(doc).off('tap', '#showCityPicker3', showCity);
                });

                _$(doc).on('tap', '#showCityPicker3', showCity);

                _$('#cityResult3').blur(function () {
                    _$(doc).on('tap', '#showCityPicker3', showCity);
                });
            }

            function showCity(event) {
                event.stopPropagation();
                cityPicker3.show(function (items) {
                    var tempValue = items[0].text + " " + items[1].text + " " + items[2].text;
                    _$(cityResult3).removeAttr('readonly').val(tempValue).attr('readonly', 'true');
                });
            }
        });
    });
})(jQuery, mui, document);